package com.hontech.bread.ui.dialog

import android.view.ViewGroup
import android.widget.Button
import com.hontech.bread.R
import kotlinx.coroutines.CompletableDeferred

class ReplenishCheckDialog : DraggableWindow(
    ViewGroup.LayoutParams.WRAP_CONTENT,
    ViewGroup.LayoutParams.WRAP_CONTENT,
    R.layout.dialog_replenish_check,
    false) {

    private val btnConfirm = view.findViewById<Button>(R.id.id_dialog_replenish_btn_confirm)
    private val btnCancel = view.findViewById<Button>(R.id.id_dialog_replenish_btn_cancel)
    private val promise = CompletableDeferred<Boolean>()

    init {
        btnConfirm.setOnClickListener {
            dismiss()
            promise.complete(true)
        }
        btnCancel.setOnClickListener {
            dismiss()
            promise.complete(false)
        }
    }

    suspend fun waitConfirm(): Boolean {
        showCenter()
        return promise.await()
    }
}




